

import BaseUI from "../../script/framwork/BaseUI";
import HallScene from "../../script/game/HallScene";
import AdCenter from "../../script/manager/AdCenter";
import Data from "../../script/manager/Data";


const {ccclass, property} = cc._decorator;

@ccclass
export default class ContinueAdPanel extends BaseUI {
    start () {
     
    }

    onDestroy()
    {
        super.onDestroy();
    }
    
    onBtnClicked(event, customEventData) {
        var btnName = event.target.name;
        console.log('btnName',btnName)
        switch (btnName) {
            case "btn_close":

                Data.user.lv--
                Data.save(true);
                HallScene.Instance.createwave();
                this.closeUI();
                break;
            case "btn_ad":
                AdCenter.Instance().play(0,(b)=>{
                    if(b)
                    {
                        let lv = Data.user.lv
                        localStorage.setItem("ad_lv_"+lv,"true")
                        HallScene.Instance.createwave();
                        this.closeUI();
                    }
                })
                break;
        }
    }

}


